<?php

namespace App\Console\Commands;

use App\Http\Model\Rebate;
use App\Http\Model\System;
use App\Http\Model\User;
use App\Http\Services\ApiServices;
use App\Lib\Search;
use Carbon\Carbon;
use DateInterval;
use DatePeriod;
use DateTime;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Redis;

class CommandChangeDDlog extends Command
{
    protected $signature = 'CommandChangeDDlog';
    /**
     * The console command description.
     *
     * @var string
     */
    protected $description = '更新dd返利数据';

    protected $rebate = 'rebate_send_log';

     /**
     * Create a new command instance.
     *
     * @return void
     */
    public function __construct()
    {
        parent::__construct();
    }

    /**
     * Execute the console command.
     *
     * @return mixed
     */
    public function handle()
    {
        $data = DB::table($this->rebate)
                    ->where('status',0)
                    ->get();
        $data = objToArray($data);
        if(!empty($data)){
            foreach($data as $v){
                DB::table($this->rebate)
                    ->where('id',$v['id'])
                    ->update(['status'=>2]);
            }
        }
    }

    
}